//
//  ZWHomeViewController.swift
//  SwiftFreshBeen
//
//  Created by Apple on 16/12/22.
//  Copyright © 2016年 zhouwnegang. All rights reserved.
//

import UIKit
import SVProgressHUD

class ZWHomeViewController: ZWBaseViewController {
    
    var homeData:ZWHomeData? //首页的基本数据
    var homeHotSaleData:[ZWHomeHotSaleModel]? //首页的热销数据
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        //获取数据
        loaddata()
        
        //获取热销数据
        loadHotSaleData()
        
    }
    
    //MARK:加载首页数据
    private func loaddata(){
        
        ZWGetDataTool.shared.getHomeData { (homedata, isSuccess) in
            
            if isSuccess == false {
                SVProgressHUD.showError(withStatus: "网络连接失败")
                return
            }
            self.homeData = homedata
        }
    }
    
    //MARK:加载首页热销数据
    private func loadHotSaleData() {
        
        ZWGetDataTool.shared.getHomeHotSaleData { (hotSaleData, isSuccess) in
            
            if isSuccess == false {
                SVProgressHUD.showError(withStatus: "网络连接失败")
                return
            }
            
            self.homeHotSaleData = hotSaleData
            print(">>%@",(self.homeHotSaleData!.first?.name)!)
        }
    }
    
    
    
    
    
}
